<#include "../common/layout/__mainlayout.html">
<#include "../common/__pagination.html">

    <!--设置面包屑-->
    <#assign pageBreadCrumbs>
        <li class="active"><a href="#">系统管理</a></li>
        <li class="active">用户管理</li>
    </#assign>
    <#assign pageCss>
        <!-- page specific plugin styles -->
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
    </#assign>

    <#assign pageJavascript>
        <script type="text/javascript">
            $(document).ready(function () {
                $('[data-rel=tooltip]').tooltip();

                if (!ace.vars['touch']) {
                    $('.chosen-select').chosen({allow_single_deselect: true});
                }

                // 清除远程modal数据
                $("#editModal").on("hidden.bs.modal", function () {
                    $(this).removeData("bs.modal");
                });

                // 删除按钮
                $("a.delete").on(ace.click_event, function (e) {
                    var currentA = this;
                    e.preventDefault();
//                bootbox.setDefaults({locale:"zh_CN"});
                    bootbox.confirm({
                                message: "确定删除该用户?",
                                buttons: {
                                    confirm: {
                                        label: "确定",
                                        className: "btn-primary btn-sm"
                                    },
                                    cancel: {
                                        label: "取消",
                                        className: "btn-sm"
                                    }
                                },
                                callback: function (result) {
                                    if (result){
                                        $.get($(currentA).attr("href"), { },function(data){
                                            if(data){
                                                window.location.href=window.location.href;
                                            }
                                        });
                                    }
                                }
                            }
                    );
                });
            });
        </script>
    </#assign>

    <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript
    currentMenu="systemFlag-userFlag">
    <div class="row">
        <div class="col-xs-12">
            <form id="searchForm" class="form-search form-inline" action="/user/userList.do">
                <label>用户名:</label><input type="text" id="username" name="username" class="input-sm input-small"
                                          value="${query.username!}"/>&nbsp;
                <label>姓名:</label><input type="text" id="name" name="name" class="input-sm input-small" value="${query.name!}"/>&nbsp;
                <select id="search_type" name="type" class="chosen-select input-md" data-placeholder="用户类型">
                    <option value=""></option>
                    <option value="0"  <#if query.type?? && query.type = 0>selected="selected"</#if>>普通用户</option>
                    <option value="1"  <#if query.type?? && query.type = 1>selected="selected"</#if>>管理员</option>
                </select>&nbsp;
                <select id="search_enable" name="enable" class="chosen-select input-md" data-placeholder="启用状态">
                    <option value=""></option>
                    <option value="0" <#if query.enable?? && query.enable = 0>selected="selected"</#if>>启用</option>
                    <option value="1"<#if query.enable?? && query.enable = 1>selected="selected"</#if>>停用</option>
                </select>&nbsp;

                <input type="submit" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>&nbsp;
                <a href="${ctx}/user/view.do"  class="btn btn-sm btn-warning" data-toggle="modal"
                   data-target="#editModal"><i class="ace-icon fa fa-plus"></i>添加</a>
            </form>
            <table id="contentTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="40" align="center">用户ID</th>
                    <th width="100" align="left">用户名</th>
                    <th width="70" align="left">昵称</th>
                    <th width="70" align="left">姓名</th>
                    <th width="60" align="left">手机号</th>
                    <th width="30" align="center">性别</th>
                    <th width="80" align="center">生日</th>
                    <th width="70" align="center">用户类型</th>
                    <th width="100" align="center">创建时间</th>
                    <th width="50" align="center">帐号状态</th>
                    <th width="40" align="center">操作</th>
                </tr>
                </thead>
                <tbody>
                <#list userList.listData as user>
                    <tr>
                        <td>${user.id!}</td>
                        <td>${user.username!}</td>
                        <td>${user.nickname!}</td>
                        <td>${user.name!}</td>
                        <td>${user.mobile!}</td>
                        <td><#if user.sex == 0> <div>男</div> <#else> <div>女</div> </#if></td>
                        <td>${user.birthday!}</td>
                        <td><#if user.type == 0> <div>普通用户</div> <#else> <div>管理员</div> </#if></td>

                        <td><#if user.createTime!??>${user.createTime?string("yyyy-MM-dd HH:mm:ss")!} <#else></#if></td>
                        <td><#if user.enable == 0> <div>启用</div> <#else> <div style="color:red">停用</div> </#if></td>
                        <td>
                            <div class="hidden-sm hidden-xs action-buttons">
                                <a class="green tooltip-success edit" href="${ctx}/user/view.do?userId=${user.id!}" data-rel="tooltip" title="编辑" data-toggle="modal" data-target="#editModal"><span class="label label-success">编辑</span></a>
                                <a class="green tooltip-warning edit" href="${ctx}/user/viewRole.do?userId=${user.id!}" class="tooltip" data-rel="tooltip" title="设置角色"  data-toggle="modal" data-target="#editModal"> <span class="label label-warning">设置角色</span></a>
                                <a class="green tooltip-warning edit" href="${ctx}/user/viewResource.do?userId=${user.id!}" class="tooltip" data-rel="tooltip" title="设置权限"  data-toggle="modal" data-target="#editModal"> <span class="label label-warning">设置权限</span></a>
                                <a class="red tooltip-error delete" href="${ctx}/user/delete.do?userId=${user.id!}" data-rel="tooltip" title="删除"> <span class="label label-danger">删除</span> </a>
                            </div>

                            <div class="hidden-md hidden-lg">
                                <div class="inline position-relative">
                                    <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                        <i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
                                    </button>

                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        <li><a href="${ctx}/user/view.do?userId=${user.id!}" class="tooltip-success edit" data-rel="tooltip" title="编辑" data-toggle="modal" data-target="#editModal"> <span class="green"><i class="ace-icon fa fa-pencil-square-o bigger-120"></i></span></a></li>
                                        <li><a href="${ctx}/user/viewRole.do?userId=${user.id!}" class="tooltip-warning" data-rel="tooltip" title="设置角色"  data-toggle="modal" data-target="#editModal"> <span class="orange"><i class="ace-icon fa fa-flag bigger-120"></i></span></a></li>
                                        <li><a href="${ctx}/user/viewResource.do?userId=${user.id!}" class="tooltip-warning" data-rel="tooltip" title="设置权限"  data-toggle="modal" data-target="#editModal"> <span class="orange"><i class="ace-icon fa fa-flag bigger-120"></i></span></a></li>
                                        <li><a href="${ctx}/user/delete.do?userId=${user.id!}" class="tooltip-error delete" data-rel="tooltip" title="删除"> <span class="red"><i class="ace-icon fa fa-trash-o bigger-120"></i></span></a></li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                </#list>
                </tbody>
            </table>
            <@pagination userList!/>
        </div>
    </div>

    <div id="editModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
            </div>
        </div>
    </div>
</@mainlayout>